package com.xy.entity;

import java.util.Date;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;

/**
 * 新闻表
 * 
 * @author 萧曳
 *
 */
public class News {
	private int newsID;
	@NotEmpty(message = "{news.newsTitle.empty}")
	@Length(message = "{news.newsTitle.lenth}")
	private String newsTitle;
	@NotEmpty(message = "{news.context.empty}")
	@Length(message = "{news.context.max}")
	private String context;
	@NotEmpty(message = "{news.contextHtml.empty}")
	@Length(message = "{news.contextHtml.max}")
	private String contextHtml;
	private String imgURL;
	private String imgRealName;
	private Date createrTime;
	private int createrID;

	public int getNewsID() {
		return newsID;
	}

	public void setNewsID(int newsID) {
		this.newsID = newsID;
	}

	public String getSubTitle() {
		if (newsTitle.length() >= 10) {
			return newsTitle.substring(0, 10) + "... ...";
		}
		return newsTitle;
	}

	public String getNewsTitle() {
		return newsTitle;
	}

	public void setNewsTitle(String newsTitle) {
		this.newsTitle = newsTitle;
	}

	public String getSubContext() {
		if (context.length() >= 10) {
			return context.substring(0, 10) + "... ...";
		}
		return context;
	}

	public String getContext() {
		return context;
	}

	public void setContext(String context) {
		this.context = context;
	}

	public String getContextHtml() {
		return contextHtml;
	}

	public void setContextHtml(String contextHtml) {
		this.contextHtml = contextHtml;
	}

	public String getImgURL() {
		return imgURL;
	}

	public void setImgURL(String imgURL) {
		this.imgURL = imgURL;
	}

	public String getImgRealName() {
		return imgRealName;
	}

	public void setImgRealName(String imgRealName) {
		this.imgRealName = imgRealName;
	}

	public Date getCreaterTime() {
		return createrTime;
	}

	public void setCreaterTime(Date createrTime) {
		this.createrTime = createrTime;
	}

	public int getCreaterID() {
		return createrID;
	}

	public void setCreaterID(int createrID) {
		this.createrID = createrID;
	}

	@Override
	public String toString() {
		return "News [context=" + context + ", contextHtml=" + contextHtml + ", createrID=" + createrID
				+ ", createrTime=" + createrTime + ", imgRealName=" + imgRealName + ", imgURL=" + imgURL + ", newsID="
				+ newsID + ", newsTitle=" + newsTitle + "]";
	}

}
